package com.stylefeng.guns.modular.owBackstageMgr.pbMgr.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.ProjectBrief;
import com.stylefeng.guns.modular.owBackstageMgr.pbMgr.service.IProjectBriefService;

/**
 * 项目简介管理控制器
 *
 * @author fengshuonan
 * @Date 2018-07-16 14:14:14
 */
@Controller
@RequestMapping("/projectBrief")
public class ProjectBriefController extends BaseController {

    private String PREFIX = "/pbMgr/projectBrief/";

    @Autowired
    private IProjectBriefService projectBriefService;

    /**
     * 跳转到项目简介管理首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "projectBrief.html";
    }

    /**
     * 跳转到添加项目简介管理
     */
    @RequestMapping("/projectBrief_add")
    public String projectBriefAdd() {
        return PREFIX + "projectBrief_add.html";
    }

    /**
     * 跳转到修改项目简介管理
     */
    @RequestMapping("/projectBrief_update/{projectBriefId}")
    public String projectBriefUpdate(@PathVariable Integer projectBriefId, Model model) {
        ProjectBrief projectBrief = projectBriefService.selectById(projectBriefId);
        model.addAttribute("item",projectBrief);
        LogObjectHolder.me().set(projectBrief);
        return PREFIX + "projectBrief_edit.html";
    }

    /**
     * 获取项目简介管理列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return projectBriefService.selectList(null);
    }

    /**
     * 新增项目简介管理
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(ProjectBrief projectBrief) {
        projectBriefService.insert(projectBrief);
        return SUCCESS_TIP;
    }

    /**
     * 删除项目简介管理
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer projectBriefId) {
        projectBriefService.deleteById(projectBriefId);
        return SUCCESS_TIP;
    }

    /**
     * 修改项目简介管理
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(ProjectBrief projectBrief) {
        projectBriefService.updateById(projectBrief);
        return SUCCESS_TIP;
    }

    /**
     * 项目简介管理详情
     */
    @RequestMapping(value = "/detail/{projectBriefId}")
    @ResponseBody
    public Object detail(@PathVariable("projectBriefId") Integer projectBriefId) {
        return projectBriefService.selectById(projectBriefId);
    }
}
